package com.huage_09;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huage_09.domain.User;

import java.util.Date;

public class JavaToJson {
    public static void main(String[] args) throws JsonProcessingException {
        User user = new User("张三", 23, "男");
        user.setDate(new Date());

        ObjectMapper obj = new ObjectMapper();
        String json = obj.writeValueAsString(user);
        System.out.println(json);
    }
}
